#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>
struct Tree
{
    char val;
    struct Tree* left;
    struct Tree* right;
};

void InOrder(struct Tree* node)
{
    if (node == NULL)
    {
        printf(" ");
        return;
    }

    InOrder(node->left);
    printf("%c ", node->val);
    InOrder(node->right);

}


struct Tree* BuyNode(char* str, int* i)
{
    struct Tree* BT = (struct Tree*)malloc(sizeof(struct Tree));
    if (BT == NULL)
    {
        perror("fail");
        return NULL;
    }

    if (str[*i] == '#')
    {
        (*i)++;
        return NULL;
    }

    BT->val = str[*i];
    (*i)++;

    BT->left = BuyNode(str, i);
    BT->right = BuyNode(str, i);

    return BT;
}

void CreateTree(char* str)
{
    int i = 0;
    struct Tree* root = BuyNode(str, &i);

    InOrder(root);
}


int main() {

    char str[100] = { 0 };
    scanf("%s", str);

    CreateTree(str);

    return 0;
}